﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Tank
{
    enum GameState
    {
        Runing,
        GameOver
    }
    class GameFrameWorl
    {
        private static GameState gameState = GameState.Runing;
        public static Graphics g;
        // 游戏初始化
        public static void Start()
        {
            SoundManger.InitSound();
            GameObjectManager.Start();
            GameObjectManager.CreateMap();
            GameObjectManager.myTank();
            SoundManger.PlayStart();
        }
        // 每一帧检测
        public static void Update() {
            //GameObjectManager.DrawMap();
            //GameObjectManager.DrawMyTank();
            //GameObjectManager.Update();
            if (gameState == GameState.Runing)
            {
                GameObjectManager.Update();
            }
            else if (gameState == GameState.GameOver)
            {
                GameOveruUpdate();
            }
        }
        // 游戏结束的时候调用
        public static void GameOveruUpdate()
        {
            int x = 300 - Properties.Resources.GameOver.Width / 2;
            int y = 300 - Properties.Resources.GameOver.Height / 2;
            g.DrawImage(Properties.Resources.GameOver, x,y);
        }
        public static void ChangeToGameOver()
        {
            gameState = GameState.GameOver;
        }

    }
}
